import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
import { itemColumns } from '../scheduling/feol/resource/data/columns';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '订单编号',
    align: "center",
    width: 150,
    dataIndex: 'orderNumber',
  },
  {
    title: '行号',
    align: "center",
    width: 100,
    dataIndex: 'rowNum',
  },
  {
    title: '产品编码',
    align: "center",
    width: 150,
    dataIndex: 'materialCode',
  },
  {
    title: '产品名称',
    align: "center",
    width: 150,
    dataIndex: 'materialName',
  },
  {
    title: '订单数量',
    align: "center",
    width: 100,
    dataIndex: 'quantity',
  },
  {
    title: '订单交期',
    align: "center",
    width: 120,
    dataIndex: 'deliveryDate',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '工艺',
    align: "center",
    width: 100,
    dataIndex: 'process',
  },
  {
    title: '工作中心',
    align: "center",
    width: 100,
    dataIndex: 'workCenter'
  },
  {
    title: '资源名称',
    align: "center",
    width: 120,
    dataIndex: 'resourceName'
  },
  {
    title: '上线日期',
    align: "center",
    width: 120,
    dataIndex: 'lineDate',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '排产数量',
    align: "center",
    width: 100,
    dataIndex: 'requiredProduction',
  },
  {
    title: '生产单号',
    align: "center",
    width: 150,
    dataIndex: 'productOrderCode',
  },
  {
    title: '图号',
    align: "center",
    width: 100,
    dataIndex: 'drawingNo',
  },
  {
    title: '上期未排量',
    align: "center",
    width: 120,
    dataIndex: 'previousUnscheduled',
  },
  {
    title: '库存',
    align: "center",
    width: 100,
    dataIndex: 'inventory',
  },
  {
    title: '是否释放',
    align: "center",
    width: 100,
    sorter: true,
    type: 'list',
    dataIndex: 'isReleased',
    enum: [
      { value: 1, title: '是' },
      { value: 0, title: '否' },
    ],
    customRender: ({ text }) => text == 0 ? "否" : text == 1 ? '是' : ''
  },
  {
    title: '是否下发',
    align: "center",
    width: 100,
    sorter: true,
    type: 'list',
    dataIndex: 'whetherIssue',
    enum: [
      { value: 1, title: '是' },
      { value: 0, title: '否' },
    ],

    customRender: ({ text }) => text == 0 ? "否" : text == 1 ? '是' : ''
  },
  {
    title: '是否关闭',
    align: "center",
    width: 120,
    dataIndex: 'isCompleted',
    customRender: ({ text }) => text == 0 ? "否" : text == 1 ? '是' : ''
  },
  {
    title: '排产日期',
    align: "center",
    sorter: true,
    width: 120,
    type: 'date',
    dataIndex: 'createTime',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
];

export const columnsList: BasicColumn[] = [
  {
    title: '订单编号',
    align: "center",
    width: 150,
    dataIndex: 'orderNumber',
  },
  {
    title: '行号',
    align: "center",
    width: 100,
    dataIndex: 'rowNum',
  },
  {
    title: '订单交期',
    align: "center",
    width: 120,
    dataIndex: 'deliveryDate',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '产品编码',
    align: "center",
    width: 150,
    dataIndex: 'materialCode',
  },
  {
    title: '产品名称',
    align: "center",
    width: 150,
    dataIndex: 'materialName',
  },
  {
    title: '图号',
    align: "center",
    width: 100,
    dataIndex: 'drawingNo',
  },
  {
    title: '生产部门',
    align: "center",
    width: 100,
    dataIndex: 'process',
  },
  {
    title: '班组',
    align: "center",
    width: 100,
    dataIndex: 'workCenter'
  },
  {
    title: '工段',
    align: "center",
    width: 120,
    dataIndex: 'resourceName'
  },
  {
    title: '排产数量',
    align: "center",
    width: 100,
    dataIndex: 'requiredProduction',
  },
  {
    title: '上线日期',
    align: "center",
    width: 120,
    dataIndex: 'lineDate',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '是否释放',
    align: "center",
    width: 100,
    sorter: true,
    type: 'list',
    dataIndex: 'isReleased',
    enum: [
      { value: 1, title: '是' },
      { value: 0, title: '否' },
    ],
    customRender: ({ text }) => text == 0 ? "否" : text == 1 ? '是' : ''
  },
  {
    title: '生产单号',
    align: "center",
    width: 150,
    dataIndex: 'productOrderCode',
  },
  {
    title: '是否下发',
    align: "center",
    width: 100,
    sorter: true,
    type: 'list',
    dataIndex: 'whetherIssue',
    enum: [
      { value: 1, title: '是' },
      { value: 0, title: '否' },
    ],

    customRender: ({ text }) => text == 0 ? "否" : text == 1 ? '是' : ''
  },
  {
    title: '是否关闭',
    align: "center",
    width: 120,
    dataIndex: 'isCompleted',
    customRender: ({ text }) => text == 0 ? "否" : text == 1 ? '是' : ''
  },
  {
    title: '排产日期',
    align: "center",
    sorter: true,
    width: 120,
    type: 'date',
    dataIndex: 'createTime',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '计划员',
    align: "center",
    sorter: true,
    width: 120,
    type: 'date',
    dataIndex: 'createBy',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "排产日期",
    field: "createTime",
    component: 'DatePicker',
    componentProps: {
      showTime: false,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    colProps: { span: 8 },
  },
	{
    label: "工作中心Id",
    field: "workCenterId",
    component: 'Input',
    show:false,
 	},
	{
    label: "工作中心",
    field: "workCenter",
    component: 'Input',
    slot: 'form-workCenter',
    colProps: {span: 8},
 	},
  {
    label: "资源名称",
    field: "resourceName",
    component: 'Input',
    colProps: { span: 8 },
  },
	{
    label: "工艺Id",
    field: "processId",
    component: 'Input',
    show:false,
    colProps: { span: 8 },
 	},
  {
    label: "加工工艺",
    field: "process",
    component: 'Input',
    slot: 'form-process',
    colProps: { span: 8 },
  },
	{
    label: "订单编号",
    field: "orderNumber",
    component: 'Input',
    // slot: 'form-orderSelect',
    colProps: {span: 8},
 	},
  // {
  //   label: "计划员",
  //   field: "createBy",
  //   component: 'JSelectUser',
  //   componentProps:{
  //       labelKey:'realname',
  //       rowKey:'username',
  //       showButton:false,
  //       isRadioSelection:false
  //   },
  //   colProps: { span: 6 },
  // },
  {
    label: "产品编码",
    field: "materialCode",
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: "生产单号",
    field: "productOrderCode",
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: "上线时间",
    field: "lineDate",
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    colProps: { span: 8 },
  },
  {
    label: "订单行号",
    field: "orderRowNum",
    component: 'Input',
    colProps: { span: 8 },
  },
	// {
  //   label: "无法按期排产",
  //   field: "isCompleted",
  //   component: 'Checkbox',
  //   colProps: {span: 6},
 	// },
];
export const searchListFormSchema: FormSchema[] = [
	{
    label: "班组",
    field: "teamGroupName",
    component: 'Input',
    colProps: {span: 8},
 	},
  {
    label: "工段",
    field: "workSectionName",
    component: 'Input',
    colProps: { span: 8 },
  },
	{
    label: "订单编号",
    field: "orderNumber",
    component: 'Input',
    colProps: {span: 8},
 	},
  {
    label: "订单行号",
    field: "orderRowNum",
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: "物料编码",
    field: "materialCode",
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: "物料名称",
    field: "materialName",
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: "MO单号",
    field: "productOrderCode",
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: "上线时间",
    field: "lineDate",
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    colProps: { span: 8 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [

  {
    label: '排产编码',
    field: 'schedulingCode',
    component: 'Input',
  },
  {
    label: '排产名称',
    field: 'schedulingName',
    component: 'Input',
  },
  {
    label: '排产方案',
    field: 'productionSchedulingSchemeId',
    component: 'Input',
    show: false
  },
  {
    label: '排产方案',
    field: 'productionSchedulingScheme',
    component: 'Input',
    slot: 'productionSchedulingSchemeSlot'
  },
  {
    label: '计划时间',
    field: 'plannedTime',
    component: 'DatePicker',
  },
  {
    label: '是否下发',
    field: 'whetherIssue',
    component: 'Select',
    componentProps: {
      options: [{ label: '是', value: 1 }, { label: '否', value: 0 }]
    }
  },
  {
    label: '计划员id',
    field: 'plannerId',
    component: 'Input',
    show: false
  },
  {
    label: '计划员',
    field: 'planner',
    component: 'Input',
  },
  {
    label: '版本号',
    field: 'versionNumber',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
//子表单数据
//子表表格配置
export const psProductionArrangementPlansItemColumns: JVxeColumn[] = [
  {
    title: '行号',
    key: 'rowNum',
    type: JVxeTypes.inputNumber,
    width: "80px",
    validateRules: [{
      required: true, message: '${title}不能为空'
    }]
  },
  {
    title: '资源名称',
    key: 'resourceName',
    type: JVxeTypes.normal,
    width: "150px",
  },
  {
    title: '工作中心',
    key: 'workCenter',
    type: JVxeTypes.normal,
    width: "150px",
  },
  {
    title: '订单编号',
    key: 'orderNumber',
    type: JVxeTypes.normal,
    width: "150px",
  },
  {
    title: '是否释放',
    key: 'isReleased',
    type: JVxeTypes.normal,
    width: "150px",
  },
  {
    title: '类别',
    key: 'category',
    type: JVxeTypes.normal,
    width: "150px",
    placeholder: '请输入${title}',
  },
  {
    title: '渠道',
    key: 'channel',
    type: JVxeTypes.normal,
    width: "150px",
    placeholder: '请输入${title}',
  },
  {
    title: '产品编码',
    key: 'productCode',
    type: JVxeTypes.normal,
    width: "150px",
    placeholder: '请输入${title}',
  },
  {
    title: '产品名称',
    key: 'productName',
    type: JVxeTypes.normal,
    width: "150px",
    placeholder: '请输入${title}',
  },
  {
    title: '单量',
    key: 'quantity',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '交期',
    key: 'deliveryDate',
    type: JVxeTypes.date,
    width: "150px",
    placeholder: '请输入${title}',
  },
  {
    title: '工艺',
    key: 'process',
    type: JVxeTypes.normal,
    width: "150px",
    placeholder: '请输入${title}',
  },
  {
    title: '上期未排量',
    key: 'previousUnscheduled',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '库存',
    key: 'inventory',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '排产数量',
    key: 'requiredProduction',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '第1周计划',
    key: 'weekOnePlan',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '第2周计划',
    key: 'weekTwePlan',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '第3周计划',
    key: 'weekThreePlan',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '第4周计划',
    key: 'weekFourPlan',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '第5周计划',
    key: 'weekFivaPlan',
    type: JVxeTypes.normal,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '1号',
    key: 'p1st',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '2号',
    key: 'p2nd',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '3号',
    key: 'p3rd',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '4号',
    key: 'p4th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',
  },
  {
    title: '5号',
    key: 'p5th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '6号',
    key: 'p6th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '7号',
    key: 'p7th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '8号',
    key: 'p8th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '9号',
    key: 'p9th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '10号',
    key: 'p10th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '11号',
    key: 'p11th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '12号',
    key: 'p12th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '13号',
    key: 'p13th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '14号',
    key: 'p14th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '15号',
    key: 'p15th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '16号',
    key: 'p16th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '17号',
    key: 'p17th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '18号',
    key: 'p18th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '19号',
    key: 'p19th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '20号',
    key: 'p20th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '21号',
    key: 'p21st',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '22号',
    key: 'p22nd',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '23号',
    key: 'p23rd',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '24号',
    key: 'p24th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '25号',
    key: 'p25th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '26号',
    key: 'p26th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '27号',
    key: 'p27th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '28号',
    key: 'p28th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '29号',
    key: 'p29th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '30号',
    key: 'p30th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '31号',
    key: 'p31th',
    type: JVxeTypes.inputNumber,
    width: "100px",
    placeholder: '请输入${title}',

  },
  {
    title: '父类id',
    key: 'parentId',
    type: JVxeTypes.hidden,
    width: "100px",
    placeholder: '请输入${title}',

  },
]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}